package com.appkubes.mall.admin.application.activity.activity.controller;

import com.appkubes.cloud.config.params.paramValid.ParamValid;
import com.appkubes.common.Response;
import com.appkubes.mall.admin.application.activity.activity.entity.dto.ActivityListDTO;
import com.appkubes.mall.admin.application.activity.activity.entity.vo.ActivityListVO;
import com.appkubes.mall.admin.application.activity.activity.entity.vo.ReleaseActivityVO;
import com.appkubes.mall.admin.application.activity.activity.service.ActivityService;
import com.appkubes.mall.admin.application.activity.activity.service.impl.ActivityServiceImpl;
import com.appkubes.mall.core.controller.BaseMallActivityController;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author: Rongjie
 * @Date: 2020/3/4
 * @Description:
 */
@Api(tags = "活动模块")
@RequestMapping("/activity")
@RestController
public class ActivityController extends BaseMallActivityController {

    @Autowired
    ActivityServiceImpl activityService;

    @ApiOperation("发布活动")
    @PostMapping("/releaseActivity")
    public Response releaseActivity(@ParamValid ReleaseActivityVO releaseActivityVO){
        activityService.releaseActivity(releaseActivityVO);
        return Response.success();
    }

    @ApiOperation("商品管理")
    @GetMapping("/activityList")
    public Response activityList(@ParamValid ActivityListVO activityListVO){
        Page page = new Page(activityListVO.getPage(), activityListVO.getSize());
        List<ActivityListDTO> activityList = activityService.activityList(activityListVO, page);
        return Response.success(activityList);
    }


}
